import {Component, Input, Output, EventEmitter} from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import {HttpServies} from '../../providers/http-servies';
import {WdjlPage} from "../wdjl/wdjl";

@Component({
    selector: 'page-mine',
    templateUrl: 'mine.html',
    providers:[HttpServies]
})
export class MinePage {
    @Input() pageNum:number=1;//当前第几页,默认1
    @Output() pageNumChange = new EventEmitter<any>();
    ceil(num){
        return Math.ceil(num);
    }
    wsJson:any=[];
    csJson:any=[];
    enJson:any=[];
    jobinten=0;
    jobfield=0;
    keyword=0;
    region=0;
    title=0;

    userInfo={
        'keyword':'',
        'jobinten':'',
        'jobfield':'',
        'region':'',
        'name':'',
        'title':'',
    }

    ionViewDidLoad() {

        this.getInfo();
        this.gesInfo();
        this.genInfo();

    }
    constructor(public navCtrl: NavController, public navParams: NavParams,private http:HttpServies) {
    }


    toContactPage(mobile) {
        this.navCtrl.push(WdjlPage,{mobile});
    }

    /*
     *
     * 找简历主页面加载方法
     * */
    getInfo(){
        this.http.httpPost('/Home/tofyr/found')
            .then(res => {//成功
                if (res && res.code == 1) {
                    // this.http.showErro(res.msg);
                    console.log(res.msg);
                    this.wsJson = res.data;
                }
            })
    }
    btnClick(pageNum){
        this.pageNum = pageNum;
        var param = "num="+this.pageNum;
        this.http.httpPost('/Home/tofyr/found',param)
            .then(res => {//成功
                if (res && res.code == 1) {
                    console.log(res.msg);
                    this.wsJson = res.data;
                }
            })
    }
    /*
     * 找简历搜索框方法
     *
     * */
    checkInfo(){
        var param = "keyword="+this.userInfo.keyword;
        this.http.httpPost('/home/tofyr/find',param)
            .then(res => {//成功
                if (res && res.code == 1) {
                    // this.http.showErro(res.msg);
                    console.log(res.msg);
                    this.wsJson = res.data;
                }else {
                    this.http.showErro('暂时没有这个职位简历');
                }
            })
    }
    /*
     * 找简历地区筛选方法
     *
     * */
    switchType( ){
        var param = "title="+this.userInfo.title +"&region="+this.userInfo.region
        this.http.httpPost('/Home/tofyr/job',param)
            .then(res => {//成功
                if (res && res.code ==1) {
                    // this.http.showErro(res.msg);
                    console.log(res.msg);
                    this.wsJson = res.data;
                }else {
                    this.http.showErro('暂时没有这个职位简历');
                }
            })
    }

    /*
    * 地区,筛选接口
    * */
    gesInfo(){
        this.http.httpPost('/Home/tofyr/place_cartridge')
            .then(res => {//成功
                if (res && res.code ==1) {
                    // this.http.showErro(res.msg);
                    console.log(res.msg);
                    this.csJson = res.data;
                }else {
                    this.http.showErro('此地区暂时无简历');
                }
            })
    }
    /*
     * 职位,筛选接口
     * */
    genInfo(){
        this.http.httpPost('/Home/tofyr/job_cartridge')
            .then(res => {//成功
                if (res && res.code ==1) {
                    // this.http.showErro(res.msg);
                    console.log(res.msg);
                    this.enJson = res.data;
                }else {
                    this.http.showErro('此地区暂时无简历');
                }
            })
    }
}
